<?php
require '../../config.php';
$codigoRuta = $_REQUEST['codigoruta'];

$query = "SELECT numeroruta,nombre,descripcion FROM rutas where idrutas = '".$codigoRuta."'";


$resultset = mysql_query($query,$conexion);

if(!$resultset)
{
    mysql_close();
    echo json_encode('error en el query: ' . mysql_error());
}
elseif(!mysql_num_rows($resultset))
{
    mysql_close();
    echo json_encode('Sin resultados');
}
else
{
	$row = mysql_fetch_array($resultset);
	
	echo "<ul class='list-unstyled'>";
		echo "<li>";
		echo "<label class='description' >N&uacute;mero de ruta: </label>";
		echo "<input id='numruta' class='element text medium' maxlength='8'   type='text' value='".$row['numeroruta']."'>";
		echo "</li>";
		echo "<li>";
		echo "<label class='description' >Nombre de la ruta: </label>";
		echo "<input id='nombre' class='element text medium' maxlength='8'   type='text' value='"._convert($row['nombre'])."'>";
		echo "</li>";
		echo "<li>";
		echo "<label class='description' >Descripci&oacute;n de la ruta: </label>";
		echo "<input id='descripcion' class='element text medium' maxlength='50'   type='text' value='"._convert($row['descripcion'])."'>";
		echo "</li>";
	echo "</ul>";
	mysql_close();
}
function _convert($content) {
	if(!mb_check_encoding($content, 'UTF-8')
	OR !($content === mb_convert_encoding(mb_convert_encoding($content, 'UTF-32', 'UTF-8' ), 'UTF-8', 'UTF-32'))) {

		$content = mb_convert_encoding($content, 'UTF-8');

		if (mb_check_encoding($content, 'UTF-8')) {
			// log('Converted to UTF-8');
		} else {
			// log('Could not converted to UTF-8');
		}
	}
	return $content;
}

?>